package com.kw.common.security.util;

import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

/**
 * Created by Medivh on 2020/11/28.
 * 愿我出走半生,归来仍是少年
 */
public class HttpMethodUtil {
	public static List<HttpMethod>  transFromRequestMethod(Set<RequestMethod> methods){
		List<HttpMethod> httpMethods = new<HttpMethod> ArrayList();
		Arrays.stream(HttpMethod.values()).forEach(httpMethod -> {
			Arrays.stream(methods.toArray()).forEach(requestMethod->{
				if(httpMethod.matches(requestMethod.toString())){
					httpMethods.add(httpMethod);
				}
			});
		});
		return  httpMethods;

	}
}
